package com.cineplanet.dew.web;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

import com.cineplanet.dew.exception.DAOExcepcion;
import com.cineplanet.dew.modelo.Pelicula;
import com.cineplanet.dew.service.PeliculaService;

public class PeliculasController extends MultiActionController{
	
	private PeliculaService peliculaService;
	
	public PeliculaService getPeliculaService() {
		return peliculaService;
	}

	public void setPeliculaService(PeliculaService peliculaService) {
		this.peliculaService = peliculaService;
	}
	
	public ModelAndView index(HttpServletRequest request,HttpServletResponse response)  {
		
		try {
			List<Pelicula> peliculas = peliculaService.listarEnCartelera();	
				
			request.setAttribute("cartelera", peliculas);
		
		} catch (DAOExcepcion e) {
			e.printStackTrace();
		}
		
		
       return new ModelAndView("mostrarPeliculas");
    }
}
